<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
           /*
           sessionStorage与localStorage相同作用：把数据存储到浏览器上

            sessionStorage与localStorage不同点：
                    sessionStorage：它只会在当前窗口生效
                    localStorage: 它是永久性存储，除非手动清空缓存，或者直接调用方法删除

            */
           function setSessionStorage(){
               sessionStorage.setItem("name", "session");
           }
           function setLocalStorage(){
               localStorage.setItem("name", "local");
           }
           function getSessionStorage(){
               var name = sessionStorage.getItem("name");
               console.debug(name);
           }
           function getLocalStorage(){
               var name = localStorage.getItem("name");
               console.debug(name);
           }
           function removeSessionStorage(){
               sessionStorage.removeItem("name");
           }
           function removeLocalStorage(){
               localStorage.removeItem("name");
           }
    </script>
</head>
<body>
    <button onclick="setSessionStorage()">sessionStorage设置值</button>
    <button  onclick="setLocalStorage()">localStorage设置值</button>
    <button  onclick="getSessionStorage()">sessionStorage获取值</button>
    <button  onclick="getLocalStorage()">localStorage获取值</button>
    <button  onclick="removeSessionStorage()">sessionStorage删除值</button>
    <button  onclick="removeLocalStorage()">localStorage删除值</button>
</body>
</html>